package com.hh.org.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hh.basic.util.PageList;
import com.hh.org.domain.Emp;
import com.hh.org.mapper.EmpMapper;
import com.hh.org.query.EmpQuery;
import com.hh.org.service.IEmpService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄浩
 * @create 2022-06-01 17:55
 */
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmpServiceImpl extends ServiceImpl<EmpMapper,Emp> implements IEmpService {
    @Resource
    private EmpMapper empMapper;
    /**
     * 高级＋分页查询
     * @param empQuery
     * @return
     */
    @Override
    public PageList<Emp> queryPage(EmpQuery empQuery) {
//        Page<Emp> empPage = new Page<>(empQuery.getCurrentPage(),empQuery.getPageSize());
//        Page<Emp> page = empMapper.selectPage(empPage,null);
//        List<Emp> empList = page.getRecords();
//        long total = page.getTotal();
        List<Emp> empList = empMapper.queryPage(empQuery);
        Integer total = empMapper.getTotal(empQuery);
        return new PageList<>(total,empList);
    }
}
